#ifndef _TEXTURE_H_
#define _TEXTURE_H_

#ifdef _WIN32
#pragma once
#endif

/**
 * A Class to load Textures and apply them to the device. 
 *
 * 04/04/2012 - Steven Hartin - Changed the textures to safe pointers and
 *                              reference counters.
 * 02/03/2012 - Stephen Gore - Created the class structure, implemented from 
 *                             UML
 *                           - Created the header file. 
 *                           - Defined all functions. 
 *                           - Made sure all functions and parameters that need 
 *                             to be are const. 
 */

#include <d3dx9.h>
#include <string>
#include <sstream>

using std::string;
using std::stringstream;

class CTexture 
{
public :            
    // Constructor
    CTexture(string path, const LPDIRECT3DDEVICE9 &device, 
             int nWidth=D3DPOOL_DEFAULT, int nHeight=D3DPOOL_DEFAULT);
    ~CTexture();

    // Copy Constructor
    CTexture(LPDIRECT3DTEXTURE9 texture);
    CTexture(const CTexture &rhs);

    // Texture settings 
    LPDIRECT3DTEXTURE9 getTexture() const;
    HRESULT loadTexture(string path, LPDIRECT3DDEVICE9 device, 
                        int nWidth=D3DPOOL_DEFAULT, 
                        int nHeight=D3DPOOL_DEFAULT);

    void applyTexture(int nTextureIndex, LPDIRECT3DDEVICE9 pDevice) const;

    int getWidth() const;
    int getHeight() const;

    void setPermanent(bool bPermanent);
    bool isPermanent() const;

private:
    // Texture 

    //TEXTURE_PTR *m_pTexture;
    LPDIRECT3DTEXTURE9 m_pTexture;

    // Path to the texture
    string m_szPath;

    int m_nWidth;
    int m_nHeight;

    bool m_bPermanent;

    D3DXIMAGE_INFO m_Info;
};
#endif